package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/user/{id}")
    // 注意，此处使用的是 GetMapping 注解，该注解的作用类似与@RequestMapping (value="/user/{id}", method= RequestMethod. GET)，@PostMapping 注解同理
    public User findById(@PathVariable Integer id) {
        return this.userService.Sel(id);
    }
}